I have a little test program (written in Python), that reads in my HTML file and writes it out as PDF. Great. But how can I control the PDF output? (Page size, orientation, etc?) At the moment, everything on the page bleeds over the right margin.
Hi
Thanks for your inquiry. I think, you can just change page setup of each section in your document before converting it to PDF: https://reference.aspose.com/words/net/aspose.words/pagesetup/
Hope this helps. Please feel free to ask if you need more assistance, I will be glad to help you.
Best regards,
thanks for the help. I’m able to get the HTML page to render as a very pretty PDF, but I’m having trouble with the content bleeding off the right edge. It does not seem to matter whether I set up the page as portrait or landscape.
Is there a way to tell Aspose to fit the content to the PDF page size?
Thanks for your inquiry. Could you please attach your input document here for testing? We will check the problem and provide you more information.
Best regards,
Here is the HTML (the content has been sanitized a bit, but the structure is the same). I think I have added all the supporting resources (css, images, etc) in the zipfile. I have also included the PDF that results from my processing.
Also, please note, it is extremely difficult and often impossible to produce Word documents which looks exactly as source HTML. This is because HTML documents are not Word documents, HTML is one page document and this format is designed for Web and not for displaying on pages.
yeah, I can do that by adding this code to my script:
db = clr.Aspose.Words.DocumentBuilder(document)
db.PageSetup.Orientation = 2
(I’m having some trouble getting to the constants via the python CLR object…but it appears that “2” is landscape.) I still get the page content bleeding off the right side, tho.
AndreyN:
Also, please note, it is extremely difficult and often impossible to produce Word documents which looks exactly as source HTML. This is because HTML documents are not Word documents, HTML is one page document and this format is designed for Web and not for displaying on pages.
Best regards,
agreed – it can be darned tough. But if we can figure out why stuff is getting pushed way over to the right, I can figure out what’s going on. I’m wondering if Aspose is either ignoring the size of the menu objects on the left and using some default value for a width, or if there’s some other resource (a style sheet or something) that I’m not pulling down.
Hi Chris,
Please note you can always check the documentation which lists the values for the enumerations. For example the values for the Orientation enumeration can be found here.
Thanks,
aske012:
Hi Chris,
Please note you can always check the documentation which lists the values for the enumerations. For example the values for the Orientation enumeration can be found here.
Thanks,
Thanks, Adam! Could I suggest that when properties and enumerations go together, they list each other in the “See Also” section? For example, I would expect to see a link to the Orientation enumeration at the bottom of the Orientation Property page.
Hi Chris,
Sure, this sounds like a good feature. I have logged this and will look into including this sometime in the future.
For now, you can find your way to the same page by clicking the property type at the start of the Property page:
[C#]
public Orientation Orientation {get; set;}
Thanks,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.