PDF.co API for Word to PDF Conversion and Parsing

PDF.co API for Word to PDF Conversion and Parsing

Hello,

I am posting this topic here because the developer community has been so helpful in the past. We have been attempting to work with PDF.co to get an answer on some issues we're having, but there must be a time zone delay, and there's just been a lot of back and forth, rather than an actual resolution. Here is what we're attempting to do:
  1. Download a .docx file from a custom module's attachments
  2. Obtain a pre-signed URL from PDF.co (they're using AWS) to work with the file
    1. URL response - url to access uploaded file
    2. Presigned URL - used to upload local file
  3. Upload the .docx file to AWS with the pre-signed URL
  4. Convert the .docx file to a PDF using the PDF.co endpoint and the URL obtained from the pre-signed URL upload
  5. Parse the PDF and return as JSON to our deluge custom function
  6. We then iterate through it and do the things we need to do
A couple more notes before we get into the code:
  1. We tried to convert the .docx file to a PDF using the Zoho Writer API and found that cell borders disappeared causing issues with the parsing at PDF.co. BUT, everything else worked great, including uploading the PDF to the pre-signed URL.
  2. We attempted to upload the file to PDF.co's built in storage, rather than the pre-signed URL, but when we download the file, and then attempt to pass it as a parameter, we get an error saying the file parameter is missing. We believe this is because the upload endpoint wants the file path. We don't know how to get that or if we even can get that from Zoho. 
  3. The pre-signed URL endpoint worked for us when we uploaded the Zoho converted PDF file.
Okay, on to the code. Thanks in advance for your help and grace with this far from perfect code! I have omitted the parsing code since we're getting hung up before then.
  1. thisRec = zoho.crm.getRecordById("Meeting_Details",thisRecId);
  2. accountId = thisRec.get("Account").get("id");
  3. newList = List();
  4. //Get all attachments on meeting detail rec
  5. response = invokeurl
  6. [
  7. url :"https://www.zohoapis.com/crm/v6/Meeting_Details/" + thisRecId + "/Attachments?fields=id,Owner,File_Name,Created_Time,Parent_Id&sort_order=desc&sort_by=Created_Time"
  8. type :GET
  9. connection:"******"
  10. ];
  11. // info response;
  12. responseNull = response.isNull();
  13. info "Attachment Response Empty: " + responseNull;
  14. if(responseNull == true)
  15. {
  16. info "No Attachments to parse";
  17. return;
  18. }
  19. //Get last uploaded file
  20. fileRec = response.get("data").get(0);
  21. info "File Rec: " + fileRec;
  22. fileId = fileRec.get("id");
  23. info "File ID: " + fileId;
  24. fileName = fileRec.get("File_Name");
  25. info "File Name: " + fileName;
  26. createdTime = fileRec.get("Created_Time");
  27. info "Created Time: " + createdTime;
  28. //Download File from Meeting Detail Rec
  29. downloadResponse = invokeurl
  30. [
  31. url :"https://www.zohoapis.com/crm/v6/Meeting_Details/" + thisRecId + "/Attachments/" + fileId
  32. type :GET
  33. connection:"******"
  34. ];
  35. info downloadResponse;
  36. fileCheck = downloadResponse.isFile();
  37. info "File? " + fileCheck;
  38. //
  39. //PDF.co Headers
  40. apiKey = "*******************";
  41. headers = Map();
  42. headers = {"x-api-key":apiKey};
  43. // Upload Permission
  44. setupFileUpload = invokeurl
  45. [
  46. url :"https://api.pdf.co/v1/file/upload/get-presigned-url?name=" + fileName + "&encrypt=false"
  47. type :GET
  48. headers:headers
  49. detailed:true
  50. ];
  51. setupFileUpload = setupFileUpload.get("responseText");
  52. // info "File Upload Response: " + setupFileUpload;
  53. uploadUrl = setupFileUpload.get("presignedUrl");
  54. info "Upload URL: " + uploadUrl;
  55. workingFileUrl = setupFileUpload.get("url");
  56. info "Working URL: " + workingFileUrl;
  57. // Actual Upload
  58. uploadHeaders = Map();
  59. uploadHeaders.put("x-api-key",apiKey);
  60. uploadHeaders.put("Content-Type","application/octet-stream");
  61. uploadParams = Map();
  62. uploadParams.put("file",downloadResponse);
  63. uploadParams.put("expiration",20);
  64. uploadParams.put("async","true");
  65. actualUpload = invokeurl
  66. [
  67. url :uploadUrl
  68. type :PUT
  69. parameters:uploadParams
  70. headers:uploadHeaders
  71. detailed:true
  72. ];
  73. info "Actual Upload: " + actualUpload;
  74. //
  75. //Convert to PDF
  76. conversionURL = "https://api.pdf.co/v1/pdf/convert/from/doc";
  77. conversionHeader = Map();
  78. conversionHeader.put("x-api-key",apiKey);
  79. conversionHeader.put("Content-Type","application/json");
  80. conversionPayload = {"url":workingFileUrl,"async":false,"inline":"true","password":"","profiles":""};
  81. conversionResult = invokeurl
  82. [
  83. url :conversionURL
  84. type :POST
  85. parameters:conversionPayload
  86. headers:conversionHeader
  87. detailed:true
  88. ];
  89. info "Conversion Result: " + conversionResult;
  90. convertedDocURL = conversionResult.get("responseText").get("url");
  91. info "Converted Doc URL: " + convertedDocURL;
We believe the issue is happening on the upload to the pre-signed URL. Once we upload the file 66-74, we then use the workingFileURL to look at the document. We are able to download, but have to use Word's recovery tool as it's corrupted. The code continues and it converts the file to a PDF, but it is unintelligible. 

Thanks so much for your help!

      • Sticky Posts

      • Function #46: Auto-Calculate Sales Margin on a Quote

        Welcome back everyone! Last week's function was about displaying the discount amount in words. This week, it's going to be about automatically calculating the sales margin for a particular quote, sales order or an invoice. Business scenario Where there is sales, there's also evaluation and competition between sales reps. A healthy rivalry helps to better motivate your employees to do smart work and close deals faster and more efficiently. But how does a sales rep get evaluated? 90% of the time, it's
      • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

        Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
      • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

        Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
      • Custom Function : Automatically send the Quote to the related contact

        Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
      • Function #50: Schedule Calls to records

        Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM

        • Recent Topics

        • Batch Tracking custom function

          Hi fellow zoho users, We have our ecommerce site setup to shopify. I have some products I want to add batch tracking too, my only issue is that it breaks our shopify workflow (create sales order, invoice, payment, package) because it requires us to manually
        • Company Multiple Branch/ Location Accounting

          Hi All, anyone know whether company can maintain their multiple Branch Accounting in Zoho  Books. It will be chart of Accounts & Master Data will be same but different report available as per per Branch. Thanks & regards, Vivek +91 9766906737
        • Is it possible to setup bin locations WITHOUT mandating batch tracking?

          Hi fellow zoho users, I'm wondering if anyone else has a similar issue to me? I only have some products batch tracked (items with shelf life expiry dates) but I am trying to setup bin locations for my entire inventory so we can do stock counting easier.
        • System-generated support email added in CC on “Reply All”

          Hi, I recently set up Zoho Desk for a client and we are trying to prevent the Zoho Desk system-generated support email address (not the mailbox used as the department’s "From address") from being automatically added in CC when agents use “Reply All” on
        • Dependent (Conditional) Fields in Zoho Bookings Forms

          Hello Zoho Bookings Team, Greetings, We would like to request the ability to create dependent (conditional) fields in Zoho Bookings registration forms. Current Limitation: There is currently no way to make one field’s available options depend on the value
        • Support “Other” Option with Free Text in Dropdown Fields

          Hello Zoho Bookings Team, Greetings, We would like to request an enhancement to the registration form fields in Zoho Bookings, specifically for dropdown fields. Current Limitation: At the moment, dropdown fields do not support an “Other” option that allows
        • Zoho CRM Email Templates 100% Width No Background How?

          Hi, On the Zoho CRM Email Templates in setup > customization > templates > new templates > I choose blank template, but still it puts in a gray background and a max width for the email. I just want to make an email that looks like an email I would send from gmail that has no background or max width. How do you do this? 
        • Optimum CRM setup for new B2B business

          Can some advise the most common way to setup Zoho CRM to handle sales for a B2B company? Specifically in how to handle inbound/outbound emails. I have spent hours researching online and can't seem to find an accepted approach, or even a tutorial. I have
        • Run a workflow after record merge

          Hello, We are wondering if there is a way to trigger a workflow after two records are merged? We have a sms service that use to text back and forth with Prospects and Contacts. To make it easy for our users, we automatically create them in this other
        • Include Suggested Articles in New Ticket Email

          When someone creates a new ticket, is there any way to include recommended knowledge base articles (like the ones Zia Suggests) in the email notification to the user? When they're waiting for a reply, it would be nice to have sent them some recommended
        • How to install Widget in inventory module

          Hi, I am trying to install a app into Sales Order Module related list, however there is no button allow me to do that. May I ask how to install widget to inventory module related list?
        • Mapping a new Ticket in Zoho Desk to an Account or Deal in Zoho CRM manually

          Is there any way for me to map an existing ticket in Zoho desk to an account or Deal within Zoho CRM? Sometimes people use different email to put in a ticket than the one that we have in the CRM, but it's still the same person. We would like to be able
        • Item Bulk Edit - Allow for Reorder Level

          We're implementing a process for using the Reorder Level field for Items, and I have to go through and add this value to a huge chunk of our Items. It's driving me bonkers that I have to do this individually through the UI rather than bulk updating. It
        • Sharing my portal URL with clients outside the project

          Hi I need help making my project public for anyone to check on my task. I'm a freelance artist and I use trello to keep track on my client's projects however I wanted to do an upgrade. Went on here and so far I'm loving it. However, I'm having an issue sharing my url to those to see progress. They said they needed an account to access my project. How do I fix this? Without them needing an account.
        • StatusIQ

          Please add StatusIQ to data sources. We using site24x7 and StatusIQ together and site24x7 integration is already there. Thanks and regards, Torsten
        • Report sorting not working

          I make extensive use of Summary reports and Pivot Tables. Most of these reports are structured such that I have several columns of "information" data that I want displayed, followed by one or more "Data" summarizations. For example, I have the following
        • This site can’t be reached mail.zoho.com took too long to respond

          In my office at any system, we couldnt able to login zoho email. it shows " This site can’t be reached mail.zoho.com took too long to respond". please fix it soon.
        • Why am I seeing deleted records in Zoho Analytics syncing with Zoho CRM?

          I have done a data sync between Zoho CRM and Zoho Analytics, and the recycle bin is empty. Why do I see deleted leads/deals/contacts in Zoho Analytics if it doesn't exist in Zoho CRM? How can I solve this problem? Thanks
        • Zoho Flow + QuickBooks Estimates – Line items not created from CRM subform

          Hi everyone, I’m trying to create QuickBooks Estimates from Zoho CRM Quotes using Zoho Flow. I’m aware that Zoho Flow’s native “Create Estimate” action does not support multiple line items, so I followed the community guidance for Invoices using a custom
        • SAP S/4 HANA Integration via ZOHO Flow

          Hi How do I change the SAP Client ID while creating a new connection ? MY client ID is 421. I believe the client id should be an input field for length 3 numbers rather then a drop down to select from a fixed set of values. Thanks
        • VLOOKUP FUNCTION PROBLEM

             Hello, i have a problem with the VLOOKUP  function in my sheet http://public.sheet.zoho.com/public/tonimoreno/indicemasacorporal2 in cell D2. This function doesn't work correctly and always returns the last content of the range. Can you help me?
        • CRM x WorkDrive: We're rolling out the WorkDrive-powered file storage experience for existing users

          Release plan: Gradual rollout to customers without file storage add-ons, in this order: 1. Standalone CRM 2. CRM Plus and Zoho One DCs: All | Editions: All Available now for: - Standalone CRM accounts in Free and Standard editions without file storage
        • Zoho Flow Completely Broken?

          Since December 13th, 100% of our flows have stopped working completely. Nothing is working or triggering??? I called support & sat on the line with them for 2 HOURS until they finally concluded it was a back-end problem on their end?? Now i'm calling
        • Print / Export full Dashboard page

          Hello Zoho team, It is currently only possible to print/export one component of a dashboard at a time. Requesting the option to print/export a full dashboard page with all components to a pdf or picture. Doing through the browser doesn't give good results.
        • emails duplicated in my outlook client

          Hello I am just new here and I have a litle problem that I do not find how to solve. I sumarise here after. Your help would be very appreciated. I have just recently contracted this zoho mail servicesservices as an initial evaluation yesterday night. I then:   - opened a free account  - created 1 initial email address ..........@domain.com  - created a second email address ..........@domain.com - proceeded with the config instructions (checking the ownership of my domain, changing MX etc... ) as
        • How to check task starting time in zoho mobile app?

          I am using the Zoho mobile app on my iPhone, and I am not able to see the task's starting and finishing times. When opening the Task information / Details, I can only see the Task start date and due date, but not the time. Is there any way to check a
        • Creating an extension in Sigma: Zoho CRM isn't selectable as a service

          I have 2 Zoho accounts which are part of 2 different workplaces. One workplace is able to select 'Zoho CRM' as a service option when creating a new extension, the other one is not. I'm not sure what the exact differences are between them. What do I need
        • List of packaged components and if they are upgradable

          Hello, In reference to the article Components and Packaging in Zoho Vertical Studio, can you provide an overview of what these are. Can you also please provide a list of of components that are considered Packaged and also whether they are Upgradable?
        • Cliq iOS can't see shared screen

          Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
        • Knowledgebase SEO

          We have a custom-domain mapped help center that is not restricted via login. I have some questions: a) will a robots.txt file still allow us to control indexing? b) do we have the ability to edit the sitemap? c) do category URLs get indexed by search
        • RouteIQ for Zoho FSM

          Beste, Zou wel top zijn dat we een RouteIQ hebben voor FSM aangezien we constant moeten zien wat de beste route is voor onze monteurs. Nu moeten we een speciale aparte programma hebben om de beste route te berrekenen voor onze monteurs aangezien de planning
        • Export Tickets from the Help Center

          Hello everyone! We are now allowing end users to export tickets directly from the help center. The ticket export allows users to: Filter tickets by Department, Priority, and Account before exporting. Download files from Export History (Setup > Data administration
        • Zoho Books Sandbox environment

          Hello. Is there a free sandbox environment for the developers using Zoho Books API? I am working on the Zoho Books add-on and currently not ready to buy a premium service - maybe later when my add-on will start to bring money. Right now I just need a
        • Super Admin Logging in as another User

          How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Moderation Update (8th Aug 2025): We are working
        • Is it possible to remove filtering options?

          My CRM has a lot of custom fields that should not be used in filters or views. Fields that are automated and exist only to store temporary values that get used in functions. These create a lot of noise in the list of fields to filter. Isn't there any
        • Function #18: Associate invoice templates automatically based on customer language

          For businesses dealing with a diverse linguistic clientele, it becomes crucial to send out invoices in the customer's preferred language to ensure effective communication. This requirement can be handled in Zoho Books by creating invoice templates in
        • Changing field types

          Question im a Zoho CRM user and curious, if I change a flied type from single or multi line text to a URL field type will i lose the data in the field or will it be converted to website link automatically. Thanks
        • Quote PDF – Header image stopped rendering suddenly

          Hello Zoho Support Team, We are facing an issue with Quote PDF templates in Zoho Books. Previously, images added inside the Quote header HTML were rendering correctly. However, recently the header image is no longer appearing, while header text still
        • Changing Default PDF Name

          Is it possible to change the default name of a PDF? As of right now, all of my quotes are named 'QT_$QuoteNumber' (i,e: 'QT_19803471298374) - would it be possible to change this to: '$CompanyName - $AccountName - $QuoteNumber' for instance?
        • Tip 2: Recursive functions in Deluge: How to dynamically run a function for a specified number of times.

          Hi folks, As part of the Zoho Creator - Tips and Tricks series every fortnight, we are back today with a new tip on Recursive functions.  Let us first quickly understand what Recursive functions are: A function that calls itself one or more times is known as a Recursive function. That is, you can execute a function to perform a particular action a specific number of times. And, at the end of each iteration, a new output is generated. Recursive functions are commonly used by programmers as it enables
        • Next Page