Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Aug 29, 2018 12:59 pm

hi
i'm using html to pdf convertion
the convertion works, but the html is too large and it gets cut off at the right side
This is my code :

Code: Select all
 Function HtmlToPdf(Html As String) As Stream
            Dim pdf = New Spire.Pdf.PdfDocument

            Dim Settings = New PdfPageSettings
            Settings.Size = PdfPageSize.A4

            Dim layout = New PdfHtmlLayoutFormat
            layout.IsWaiting= False
            layout.FitToPage = Clip.Width     ' tried this - didn't help

            Dim Thread = New Thread(Sub()
                                        pdf.LoadFromHTML(Html, False, Settings, layout)
                                    End Sub)
            Thread.SetApartmentState(ApartmentState.STA)
            Thread.Start()
            Thread.Join()

            Dim Stream = New MemoryStream
            pdf.SaveToStream(Stream)
            Return Stream
        End Function


any ideas ?

Thank you

YonatanT
 
Posts: 2
Joined: Wed Aug 29, 2018 12:41 pm

Thu Aug 30, 2018 8:41 am

Hello Yonatan,

Thanks for your inquiry.
Please try to set the size of the page to be larger, such as A2/A3, so that it can fully render the contents of HTML instead of clipping it.
Code: Select all
Settings.Size = PdfPageSize.A2;

Besides, you could try another way(Convert HTML to PDF with New Plugin) to do conversion, which has a better performance. If the issue still occurs, please provide your input Html and output Pdf to help us further investigate it. You could send them to us via email([email protected]).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1535
Joined: Wed Apr 25, 2018 3:20 am

Thu Aug 30, 2018 1:54 pm

Hello Lisa

thank you for the help
i did set it to A3 and it solved the issue

i did lose a little of the resolution but i'm fine with that

Thank you!

YonatanT
 
Posts: 2
Joined: Wed Aug 29, 2018 12:41 pm

Fri Aug 31, 2018 1:15 am

Hello Yonatan,

Thanks for your quick reply.
If you have other questions, please do not hesitate to contact us. Wish you all the best.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1535
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron