Diagram export to PDF

Hi, i want to export syncfusion diagram graphics to pdf. If the diagram size has only one page, everythin is working fine. but if the diagram size is larger than one page, the export to pdf is cutting the image to one page. i´ve try scalling the image to fit in one page, but it dosn´t look very fine ! Is there a way, to create new pages while drawing the image ? I´ve try AutoCreatePages = true but i see no effect ... Also if i create new pages before i draw the image has no effect. Any idea ... cu kai

10 Replies

JF Jeff Fansler February 22, 2005 06:47 PM UTC

I would like to know how to export a diagram to a PDF as well. Is the only way to export the Diagram as an image and then inserting that into a PDF? It''d be nice if there was a method that worked similar to the Diagram.CreatePrintDocument. >Hi, >i want to export syncfusion diagram graphics to pdf. If the diagram size has only one page, everythin is working fine. but if the diagram size is larger than one page, the export to pdf is cutting the image to one page. i´ve try scalling the image to fit in one page, but it dosn´t look very fine ! Is there a way, to create new pages while drawing the image ? I´ve try AutoCreatePages = true but i see no effect ... Also if i create new pages before i draw the image has no effect. Any idea ... >cu >kai >


JF Jeff Fansler February 23, 2005 04:29 PM UTC

I was able to get a diagram to output to PDF, but one of my custom symbols had alignment issues. Here''s the code I used: Metafile mf = null; using (Graphics g = _layoutForm.Diagram.CreateGraphics()) { IntPtr hDC = g.GetHdc(); mf = new Metafile(hDC, new Rectangle(_layoutForm.Diagram.View.Location , _layoutForm.Diagram.View.Size), MetafileFrameUnit.Pixel, EmfType.EmfOnly); g.ReleaseHdc(hDC); g.Dispose(); } using (Graphics g = Graphics.FromImage(mf)) { _layoutForm.Diagram.Model.Draw(g); } PDFDocument pdfDoc = new PDFDocument(); IPDFPage firstPage = pdfDoc.Pages[0]; firstPage.Graphics.DrawImage(new PointF(0,0), mf); pdfDoc.Save(@"c:\test.pdf"); mf.Save(@"c:\test.wmf"); I checked the metafile and the custom symbol did not have any allignment issues. Any suggestions?


AD Administrator Syncfusion Team February 24, 2005 12:22 PM UTC

Hi Kai, The current version does not have support for inserting images that span over multiple pages. However, this issue has been addressed internally and the next version will automatically make the image continue on to the next PDF Page. Thanks, Stephen. >Hi, >i want to export syncfusion diagram graphics to pdf. If the diagram size has only one page, everythin is working fine. but if the diagram size is larger than one page, the export to pdf is cutting the image to one page. i´ve try scalling the image to fit in one page, but it dosn´t look very fine ! Is there a way, to create new pages while drawing the image ? I´ve try AutoCreatePages = true but i see no effect ... Also if i create new pages before i draw the image has no effect. Any idea ... >cu >kai >


FI Filip May 24, 2005 09:18 AM UTC

I have a similar problem! I have a procedure to create a pdf-file which gets a string as a parameter. Depending on the length of the string, I decide whether to use DrawText or DrawMultiText which works fine... the only problem I get is when I get a string consisting out of multiple lines that has more lines than there is place left on the page I''m drawing on... is there a way to make the text go further on the next page or perhaps a way to split my string into two parts based on the number of lines so that I can put the first part on the end of the first page and the second part on the second page? I hope I explained this properly and that I will find help here! :) thanks anyway!


AD Administrator Syncfusion Team May 26, 2005 02:44 AM UTC

Hi Filip, You can make text span several pages by setting PageBreak behavior IPDFGraphicState props = pdfDoc.CreateGraphicState(); props.BreakBehaviour = AutoBreakBehaviour.FullBreak; Here is a sample Please let me know if you have any questions. Thanks, Stephen. >I have a similar problem! > >I have a procedure to create a pdf-file >which gets a string as a parameter. >Depending on the length of the string, I decide whether to use DrawText or DrawMultiText which works fine... >the only problem I get is when I get a string >consisting out of multiple lines that has more >lines than there is place left on the page I''m >drawing on... is there a way to make the text go further on the next page or perhaps a way to split my string into two parts based on the number of lines so that I can put the first part on the end of the first page and the second part on the second page? >I hope I explained this properly and that I will find help here! :) > >thanks anyway! >


AD Administrator Syncfusion Team May 27, 2005 12:48 PM UTC

Thank you for the quick response! But i still have a problem. My document consists out of text and images, which alternates. So i can start at page 1 with a string that makes the title, then an image under that title, then another string with a description (consisting out of 1 or more lines), another string with a title, another image, another string with a description (consisting out of 1 or more lines) and so on... so at one point i get to the bottom of my page and i have to print a description with consists out of multiple lines (maybe even 2 pages of text) now when i call pdfDoc.Graphics.DrawMultiText, it doesn''t have a parameter that says on what page i am and i get an IndexOutOfRangeException. still trying to find a way to solve this though ;) but any more help would be greatly appreciated :) >Hi Filip, > >You can make text span several pages by setting PageBreak behavior > IPDFGraphicState props = pdfDoc.CreateGraphicState(); > props.BreakBehaviour = AutoBreakBehaviour.FullBreak; > >Here is a sample > >Please let me know if you have any questions. > >Thanks, > >Stephen. > >>I have a similar problem! >> >>I have a procedure to create a pdf-file >>which gets a string as a parameter. >>Depending on the length of the string, I decide whether to use DrawText or DrawMultiText which works fine... >>the only problem I get is when I get a string >>consisting out of multiple lines that has more >>lines than there is place left on the page I''m >>drawing on... is there a way to make the text go further on the next page or perhaps a way to split my string into two parts based on the number of lines so that I can put the first part on the end of the first page and the second part on the second page? >>I hope I explained this properly and that I will find help here! :) >> >>thanks anyway! >>


FI Filip May 30, 2005 01:45 PM UTC

Forget about my previous post! That problem with the index out of range is solved. Bad coding by me :-) BUT... there is still one minor problem. let''s say my page has a height of 600 (pixels or point or whatever) and i have reached 500... the next string i''m about to print is 12 lines with each line 10 in height (which means 120 points)... now, what i would expect is that DrawMultiText fills my page untill the bottom and then makes a new page and puts the rest (last 2 lines) on the next page. But it does not do that... it leaves the last 100 points of my current page blank and creates a new page and starts printing my text on the newly created page. (even if i do this:) IPDFPage PdfPage; PdfPage = this.m_pdfDoc.Pages[m_intCurrentPage]; PdfPage.Graphics.DrawMultiText(new Rectangle(p_Point.X,p_Point.Y,(int)PdfPage.DrawingWidth,m_intHoogte),p_strText,this.m_labelHeaderProps.TP_Font,this.m_labelHeaderProps.TP_Props); my question: Is there a way of filling up my current page completely before DrawMultiText creates that new page and then print the rest of the text on that new page? Or will i have to find a way to split up my string at line 10 and do it myself? :-) thanks for your time and help! greetings, Filip >Thank you for the quick response! > >But i still have a problem. >My document consists out of text and images, >which alternates. So i can start at page 1 with a string that makes the title, then an image under that title, then another string with a description (consisting out of 1 or more lines), another string with a title, another image, another string with a description (consisting out of 1 or more lines) and so on... >so at one point i get to the bottom of my page and i have to print a description with consists out of multiple lines (maybe even 2 pages of text) > >now when i call pdfDoc.Graphics.DrawMultiText, it doesn''t have a parameter that says on what page i am and i get an IndexOutOfRangeException. > >still trying to find a way to solve this though ;) >but any more help would be greatly appreciated :) >>Hi Filip, >> >>You can make text span several pages by setting PageBreak behavior >> IPDFGraphicState props = pdfDoc.CreateGraphicState(); >> props.BreakBehaviour = AutoBreakBehaviour.FullBreak; >> >>Here is a sample >> >>Please let me know if you have any questions. >> >>Thanks, >> >>Stephen. >> >>>I have a similar problem! >>> >>>I have a procedure to create a pdf-file >>>which gets a string as a parameter. >>>Depending on the length of the string, I decide whether to use DrawText or DrawMultiText which works fine... >>>the only problem I get is when I get a string >>>consisting out of multiple lines that has more >>>lines than there is place left on the page I''m >>>drawing on... is there a way to make the text go further on the next page or perhaps a way to split my string into two parts based on the number of lines so that I can put the first part on the end of the first page and the second part on the second page? >>>I hope I explained this properly and that I will find help here! :) >>> >>>thanks anyway! >>>


AD Administrator Syncfusion Team June 21, 2005 12:11 PM UTC

Hi Filip, Sorry for the delay in getting back to you. This seems to be a bug so I have filed a bug report with the development team. You can track the status of this issue here http://www.syncfusion.com/support/issues/pdf/Default.aspx?ToDo=view&questId=443 For now you would have to manually measure the height using the MeasureHeightInLines method of the graphics class. Thank you for your patience. Best regards, Stephen. >Forget about my previous post! >That problem with the index out of range is solved. Bad coding by me :-) > >BUT... there is still one minor problem. >let''s say my page has a height of 600 (pixels or point or whatever) and i have reached 500... >the next string i''m about to print is 12 lines with each line 10 in height (which means 120 points)... > >now, what i would expect is that DrawMultiText fills my page untill the bottom and then makes a new page and puts the rest (last 2 lines) on the next page. > >But it does not do that... it leaves the last 100 points of my current page blank and creates a new page and starts printing my text on the newly created page. >(even if i do this:) > >IPDFPage PdfPage; >PdfPage = this.m_pdfDoc.Pages[m_intCurrentPage]; > >PdfPage.Graphics.DrawMultiText(new Rectangle(p_Point.X,p_Point.Y,(int)PdfPage.DrawingWidth,m_intHoogte),p_strText,this.m_labelHeaderProps.TP_Font,this.m_labelHeaderProps.TP_Props); > >my question: >Is there a way of filling up my current page completely before DrawMultiText creates that new page and then print the rest of the text on that new page? >Or will i have to find a way to split up my string at line 10 and do it myself? :-) > >thanks for your time and help! > >greetings, > >Filip >>Thank you for the quick response! >> >>But i still have a problem. >>My document consists out of text and images, >>which alternates. So i can start at page 1 with a string that makes the title, then an image under that title, then another string with a description (consisting out of 1 or more lines), another string with a title, another image, another string with a description (consisting out of 1 or more lines) and so on... >>so at one point i get to the bottom of my page and i have to print a description with consists out of multiple lines (maybe even 2 pages of text) >> >>now when i call pdfDoc.Graphics.DrawMultiText, it doesn''t have a parameter that says on what page i am and i get an IndexOutOfRangeException. >> >>still trying to find a way to solve this though ;) >>but any more help would be greatly appreciated :) >>>Hi Filip, >>> >>>You can make text span several pages by setting PageBreak behavior >>> IPDFGraphicState props = pdfDoc.CreateGraphicState(); >>> props.BreakBehaviour = AutoBreakBehaviour.FullBreak; >>> >>>Here is a sample >>> >>>Please let me know if you have any questions. >>> >>>Thanks, >>> >>>Stephen. >>> >>>>I have a similar problem! >>>> >>>>I have a procedure to create a pdf-file >>>>which gets a string as a parameter. >>>>Depending on the length of the string, I decide whether to use DrawText or DrawMultiText which works fine... >>>>the only problem I get is when I get a string >>>>consisting out of multiple lines that has more >>>>lines than there is place left on the page I''m >>>>drawing on... is there a way to make the text go further on the next page or perhaps a way to split my string into two parts based on the number of lines so that I can put the first part on the end of the first page and the second part on the second page? >>>>I hope I explained this properly and that I will find help here! :) >>>> >>>>thanks anyway! >>>>


AD Administrator Syncfusion Team June 30, 2005 02:45 PM UTC

thank you for filing a bug-report! :) i hope this will be resolved soon, because it is very important for our application. i will be patience though, because it''s useless to implement a method for it myself if it''s going to be solved in the next version! thanks for everything!


AD Administrator Syncfusion Team July 17, 2006 08:51 PM UTC

A related issue seems to be that the IPDFGraphics.MeasureString(string, IPDFFont) method returns the incorrect height for cases that where it should identical, where the font is the same and the input text are identical height in Windows Forms. In these cases the height returned is either correct or twice what it should be, making it impossible to do any dynamic layout of the form.

Loader.
Up arrow icon