colums are breaking during the conversion from xlsx to pdf - pdf

I am trying to convert the excel sheet into pdf. I'm managing to do the conversion but unfortunately all of my columns are not appearing in a single pdf page. My columns are automatically breaking and it's moving to the next pdf page.
This is my code
var convertSheet = await convertApi.ConvertAsync("xlsx", "pdf",
new ConvertApiFileParam("File", #"C:\ConvertPdf\xyz.xlsx")
);
await convertSheet.SaveFilesAsync(#"C:\ConvertPdf\");
Can you please help me to identify how to keep all the columns in single page.

Related

How to create different file names for every new document in Photoshop?

I have an A4 size document with 6 Photos, while I am trying to cut one photo from the original and create a new document the new file name is created as "Untitled-1".
Since I am using an Action to cut from original and paste it into the new document, every new file is opened with same name as "Untitled-1" and while saving it replaces the existing.
Is there any way to make every new document with sequence number or any different names for each file while create new document in Photoshop?
Or else please suggest if any script is available for the same.
Please find below screenshot for your clear understanding.
thanks in advance.
Full page image
Every new document name
Are you familiar with slices? It's beneath the crop tool - You can slice up your document the way you want it, then Export > Save for web, then each slice will save as an individual file.

Force google spreadsheet to wait until cell calculation finish and then export to pdf

In my google spreadsheet file I have many custom function, that perform requests to my server and download some data. I need to automatically export it to PDF and then send on particular email.
I wrote like this:
function sendPDF() {
var pdf = DriveApp.getFileById(SpreadsheetApp.getActive().getId()).getAs('application/pdf').getBytes();
var attach = {fileName:'MyPDF.pdf',content:pdf, mimeType:'application/pdf'};
MailApp.sendEmail("example#email.com", "PDF test", "test", {attachments:[attach]});
}
And add trigger on time, that will execute this function every hour. The problem is, that with one spreadsheet I get PDF without downloaded data, and with another spreadsheet I get We're sorry, a server error occurred. Please wait a bit and try again. (line 44, file "Code") error.
How can I force google spreadsheet to wait until data will be downloaded and after download send me final PDF?
Sadly, without the needed reputation I cannot comment above.
Why not having this as a separate function like you have now and just call the function in your main function that fetches the url and downloads the data.
You can even write the downloaded data on a separate spreadsheet and insert an IF function that when cells are not empty execute the pdf script! After executing the script clear() and loop if necessary.

Cloning a form field with all styles using PDFBox

We need to fill out a form for our customers and get a PDF, which they can print, sign & send back. As the PDF has to change frequently, we use PDF templates with form fields, which are fill by our tool (pdftk). For various reasons I would like to switch to PDFBox (one is, that it required us to split the templates in individual pages and save them to disk, fill them and then merged them together again). So far everything works fine.
But I struggle with the page numbering. As the form is combined out of multiple templates, I have to fix the page number with PDFBox. So far, we used a styled input field page_num on every page. But since they all have the same name, I can't fill them individually.
Can I somehow split or clone the fields and give them individual names, so I can fill them individually? Of course, the styling should stay like it is.
With the help of the PDFBox guys I've got it to work. My solution is using JRuby, but I think you could pretty easily translate it to Java (remove the Java::OrgApachePdfbox... namespace).
doc = Java::OrgApachePdfboxPdmodel::PDDocument.load("input.pdf")
form = doc.getDocumentCatalog.getAcroForm
pages = doc.getDocumentCatalog.getAllPages.toArray.to_a
page_num = form.getField("page_num")
string = page_num.getDictionary
.getDictionaryObject(Java::OrgApachePdfboxCos::COSName::DA)
page_num.getKids.to_array.each do |widget|
widget_dict = widget.getDictionary
widget_dict.setString(Java::OrgApachePdfboxCos::COSName::DA, string.getString)
field = Java::OrgApachePdfboxPdmodelInteractiveForm::PDTextbox.new(
form,
widget_dict
)
field.setParent(page_num)
page = (pages.index(widget.getPage) + 1).to_s
field.setPartialName("page_num_#{page}")
field.setValue(page)
end
doc.save("output.pdf")

How to autofit table cells in Birt report to fit content when generating pdf

I have a BIRT Report using a table with variable amounts of data. If there is too much data then when I generate a pdf the table doesn't resize to fit everything. It renders fine using the HTML output but with a pdf a lot of my information is getting cut off.
How can I fix my report so no matter how much data is in the table it'll resize to fit when I generate the pdf?
In your InterfaceIPDFRender, set your PAGE_OVERFLOW = FIT_TO_PAGE_SIZE and that should do it
This should do the trick:
In the report properties, use Layout Preference: Fixed Layout.
When running the report as PDF:
IRenderOption options = new RenderOption();
PDFRenderOption pdfOptions = new PDFRenderOption(options);
pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, IPDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES);
pdfOptions.setOption(IPDFRenderOption.PDF_TEXT_WRAPPING, true);
pdfOptions.setOption(IPDFRenderOption.PDF_HYPHENATION, true);
runAndRenderTask.setRenderOption(options);
runAndRenderTask.run();

Getting a merged cell width on Google Spreadsheet API

I'm using the Google Spreadsheet API to convert a document containing workers shifts into event calendars.
The only problem is that shifts are represented by merged cells according to days and hours (with days and hours as rows and different work slots as cols), and when I read a certain cell, which is merged and spans over 6 cells, I cannot get the cells certain width or its merged area.
For example:
If I try to get the values between (4C:4E) I will get "Bob, , ," and not "bob,bob,bob", and I cannot even find a way to know how many cells "bob" take.
Do you guys know how can I know how many cells the merged one spread to? Or at least it's total width.
Thanks in advance!
Download from google drive as html, see:
Get FontStyle information from Google spreadsheet into appengine
Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).build();
File file = driveService.files().get(this.spreadsheetKey).execute();
String downloadUrl = file.getExportLinks().get("application/pdf");
downloadUrl = downloadUrl.replaceFirst("exportFormat=pdf", "exportFormat=html");
downloadUrl = appendWorksheetGid(downloadUrl); // adds "&gid="+sheetGid
HttpResponse resp =
driveService.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl))
.execute();
System.out.println("downloadUrl:"+downloadUrl);
InputStream fileContent = resp.getContent();
extractStyleFromHtml(fileContent,downloadUrl);
extractStyleFromHtml uses Jsoup - (Jsoup impressed me)
It's not possible via spreadsheet API. I was looking for same. Google admits the same in their documentation.
The literal value of the cell element is the calculated value of the
cell, without formatting applied. If the cell contains a formula, the
calculated value is given here. The Spreadsheets API has no concept of
formatting, and thus cannot manipulate formatting of cells.
Related question:
Set cell format in Google Sheets spreadsheet using its API & Python
One alternate way can be to download the doc in excel format programmatically. It will contain formatting information. Then using excel API to extract the info.